package br.com.salao.rest;

import java.util.HashMap;
import java.util.Map;

import javassist.NotFoundException;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import br.com.salao.bean.Servicos;
import br.com.salao.model.ServicosModel;


@Path("/servico")
public class ServicosService {

	private Map<Integer, Servicos> listaServicos;

	public ServicosService(){}

	@GET
	@Path("/{id}.json")	
	@Produces({MediaType.APPLICATION_JSON})
	public Servicos getServico(@PathParam("id") int id) throws NotFoundException{

		Servicos servicos;
		ServicosModel model = new ServicosModel();
		listaServicos = new HashMap<Integer, Servicos>();
		servicos = model.find(id);
		
		if(servicos != null){
			listaServicos.put(servicos.getId(), servicos);			
		}else{
			throw new NotFoundException("Servico nao encontrado");
		}
		return listaServicos.get(id); 

	}

}


